import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import { resolve } from "path";

// https://vite.dev/config/
export default defineConfig({
  plugins: [react()],

  resolve: {
    alias: {
      "@": resolve(__dirname, "./src"),
    },
  },

  css: {
    // modules: false,
    preprocessorOptions: {
      scss: {
        // api: "modern-compiler", // or 'modern'
        javascriptEnabled: true,
        additionalData: '@import "./src/styles/common/index.scss";',
      },
    },
  },

  server: {
    host: "localhost",
    port: 8080,
    // hmr: false,
    // open: true,
    proxy: {
      "/api": {
        target: "后端接口域名",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ""),
      },
    },
  },
});
